# !/usr/bin/env python
# coding=utf-8
# @Time    : 2018/3/12 14:59
# @Author  : 6imensiva
# @Site    : https://gitee.com/dimensiva/app_server.git
# @File    : __init__.py.py
# @Software: PyCharm
# @Version: 2.7.5

from log.log4py import log4py
import platform
import os
import pymysql
pymysql.install_as_MySQLdb()


class Log4Py:

    def __init__(self):
        self.log4py = log4py.Logger().get_instance(self)

    def error(self, str):
	    self.log4py.error(str)

    def info(self, str):
        self.log4py.info(str)


mylog = Log4Py()
sysstr = platform.system()
if (sysstr == "Windows"):
    mylog.log4py.set_target("c:/aaa.log")
    mylog.log4py.set_rotation(log4py.ROTATE_DAILY)
    # yesterday = time() - 60 * 60 * 24
    # utime("c:/aaa.log", (yesterday, yesterday))
else:
    if not os.path.exists('logs/mylog.log'):
        os.makedirs('logs')
    mylog.log4py.set_target("logs/mylog.log")
    mylog.log4py.set_rotation(log4py.ROTATE_DAILY)
    # yesterday = time() - 60 * 60 * 24
    # utime("log4py-rotation.log", (yesterday, yesterday))